const install = (Vue,vm) => {
    const check = (auth = false) =>
    {
        let LoginAdmin = uni.getStorageSync('admin');

        if(!LoginAdmin || JSON.stringify(LoginAdmin) === '{}')
        {
            uni.showToast({
                title:'请先登录',
                icon:'error',
                complete:() => {
                    if(auth === true)
                    {
                        setTimeout(() => {
                            uni.$u.route({
                                type:'tab',
                                url:'pages/admin/index'
                            })
                        },1500);
                    }
                }
            });

            return false;
        }

        return true;
    }

    vm.$u.auth = {
        check
    }
}

export default {
    install
}